package com.plugin.sproutcore.core.resources.properties;

import java.util.TreeSet;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamImplicit;

/**
 * The root of the SproutCore properties. Holds information about SproutCore 
 * projects.
 */
@XStreamAlias(value="sproutcore")
public class SproutCoreProperties 
{
	/**
	 * Holds all the SproutCore projects that are in an eclipse project.
	 */
	@XStreamImplicit(itemFieldName="projects")
	TreeSet<SproutCoreProject> scProjects;
	
	/**
	 * The last selected project.
	 */
	@XStreamAsAttribute
	private String lastScProjectTarget;
	
	public SproutCoreProperties() {}

	public TreeSet<SproutCoreProject> getScProjects() 
	{
		if (scProjects == null) {
			scProjects = new TreeSet<SproutCoreProject>();
		}
		return scProjects;
	}

	public void setScProjects(TreeSet<SproutCoreProject> scProjects) {
		this.scProjects = scProjects;
	}
	
	public static SproutCoreProperties getDefaultProperties()
	{
		SproutCoreProperties properties = new SproutCoreProperties();
		return properties;
	}

	public void setLastScProjectTarget(String lastScProjectTarget) 
	{
		// save if it has changed
		this.lastScProjectTarget = lastScProjectTarget;
	}
	public String getLastScProjectTarget() {
		return lastScProjectTarget;
	}
}
